import type { AxiosInstance } from "axios";
//@ts-ignore
import {useLoading} from '../hooks/useloading'
export default (http: AxiosInstance) => {
    http.interceptors.request.use((config) => {
        let ul = useLoading()
        ul()
        //发送的时候如果有token就封装到请求头中
        if (sessionStorage.token != undefined) {
            //@ts-ignore
            config.headers.Authorization =sessionStorage.token
        }
        return config
    }, (err) => {
        let ul = useLoading()
        ul()
        return Promise.reject(err)
    })
}